<?php /* Smarty version 2.6.18, created on 2010-03-16 11:25:47
         compiled from dispatchorder.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'date_format', 'dispatchorder.tpl', 69, false),)), $this); ?>
<div id="blanket" style="display:none;"></div>
<div id="selectsupplier" style="position:absolute;background-color:#fff;width:400px;z-index: 1002;display:none;"></div>
<style type="text/css"> 
<?php echo '
	#f_div { display:none; position:absolute; z-index:10000;} 
'; ?>

</style>
<script type="text/javascript">	
	//var calendar1 = new ekimo_calendar("f_show","dispatch_date","Dispatch date", "f_div");
	<?php echo '
										Calendar.setup({
									        inputField     :    "user[dispatchdate]",     // id of the input field
									        ifFormat       :    "%Y-%m-%d" ,    // format of the input field
									        displayArea    :    "fromContainer",
									        daFormat       :    "%Y-%m-%d",      // format of the display area
									        button         :    "f_trigger_c1",  // trigger for the calendar (button ID)
									        align          :    "CR",           // alignment (defaults to "Bl")
									        singleClick    :    true,
											//onUpdate	   :    endDateChanged, //event to call after calendar is closed
									        weekNumbers    :    false
									    });
	'; ?>

</script>
<form name="mainForm" method="POST" id="mainForm">
    	<h1>Dispatch Order</h1>
        <div class="blue">
        <p class="right"><a href="javascript:void(0);" onclick="showsearch('search');"><img id="show_arrow" alt="Show Search" src="/app/default/www/images/arrow-down.png" border="0"/></a></p>
		<p class="left"><div style="display:block;" id="search">
			<table border="0" width="100%">
				<tr>
					<td width="15%">Customer Name:</td>
					<td id="customer">
						<select name="search[customer]" id="user[customer]" onchange="getPo();">
								<option value="">--- Select Customer ---</option>
							<?php $_from = $this->_tpl_vars['customers']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['item']):
?>
								<option value="<?php echo $this->_tpl_vars['item']['org_id']; ?>
"><?php echo $this->_tpl_vars['item']['supplier']; ?>
</option>
							<?php endforeach; endif; unset($_from); ?>
						</select>
					</td>
				</tr>
				<tr>
					<td>P.O. Number:</td>
					<td id="podetail"><select name="search[pono]" id="search[pono]">
							<option value="">--- Select P.O. ---</option>
							<?php $_from = $this->_tpl_vars['supplier']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['suppitem']):
?>
								<option value="<?php echo $this->_tpl_vars['suppitem']['org_id']; ?>
"><?php echo $this->_tpl_vars['suppitem']['name']; ?>
</option>
							<?php endforeach; endif; unset($_from); ?>
					</select>&nbsp;&nbsp;<input type="button" value="Load &gt;&gt;" onclick="load();"></td>
				</tr>
				<?php if ($this->_tpl_vars['usertype'] != 'Exporter'): ?>
				<tr>
					<td><input type="checkbox" name="withoutpo" id="withoutpo" value="1" onclick="dispatchWithoutPo(this);">Dispatch Without PO</td>
				</tr>
				<?php endif; ?>
			</table>
		</div></p>
        
        </div>
        <div class="content"></div>
		
		<div class="blue" id="pohead">
		<table border="0" width="100%">
			<tr>
				<td>Customer Name</td>
				<td><input type="text" readonly value=""></td>
				<td>Dispatch Date</td>
				<td>
					<!-- label for="f_date">
						<input readonly id="dispatch_date" type="text" name="user[dispatchdate]" value="<?php echo ((is_array($_tmp=$this->_tpl_vars['date'])) ? $this->_run_mod_handler('date_format', true, $_tmp, "%Y-%m-%d") : smarty_modifier_date_format($_tmp, "%Y-%m-%d")); ?>
">
						<a href="javascript:void(0);" id="f_show"><img style="margin-top:3px;" alt="Calendar" src="/app/default/www/images/calendar.jpg" border="0"/></a>
						<div id="f_div"></div>	
					</label -->			
					<span id="fromContainer" class="formfields" style="width:80px; display:block; float:left; height:15px; text-align:center;"><?php echo ((is_array($_tmp=$this->_tpl_vars['date'])) ? $this->_run_mod_handler('date_format', true, $_tmp, "%Y-%m-%d") : smarty_modifier_date_format($_tmp, "%Y-%m-%d")); ?>
</span>
					<input style="float:left" type="hidden" name="user[dispatchdate]"  value="<?php echo $this->_tpl_vars['date']; ?>
" id="user[dispatchdate]"> 
					<input style="float:left" type="image" src="/app/default/www/images/calendar.jpg" align="absmiddle" id="f_trigger_c1" style="cursor: pointer; border: 0px ;" title="Date selector"  />
					<input type="hidden" name="dateYui" value="user[dispatchdate]/fromContainer/f_trigger_c1">
				</td>
				<td>Mode of Transport</td>
				<td><select name="user[transport]">
					<option value="">--- Select ---</option>
					<?php $_from = $this->_tpl_vars['shipmethod']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['ship']):
?>
						<option value="<?php echo $this->_tpl_vars['ship']['ship_method_id']; ?>
"><?php echo $this->_tpl_vars['ship']['name']; ?>
</option>
					<?php endforeach; endif; unset($_from); ?>
				</select></td>
			</tr>
			<tr>
				<td>P.O Number</td>
				<td><input type="text" readonly value=""></td>
				<td>P.O Date</td>
				<td><input type="text" name="user[podate]" readonly></td>
				<td>Airline/Shipping Co</td>
				<td><select name="user[airline]">
					<option value="">--- Select ---</option>
				</select></td>
			</tr>
			<tr>
				<td>Carrier Code</td>
				<td><input type="text"  value=""></td>
				<td>Total Freight</td>
				<td><input type="text"  value=""></td>
			</tr>
		</table>
		</div>
		<div class="content"></div>
		<div id="detail">
		</div>
		
</form>

<script language="javascript">
<?php echo '

	function load(){
		doajaxAction("/account/dispatchPohead/",1,\'pohead\',document.getElementById(\'mainForm\'));
		doajaxAction("/account/dispatchPodetail/",1,\'detail\',document.getElementById(\'mainForm\'));
		document.getElementById(\'withoutpo\').checked = false;
	}
	
	function showsearch(div) {
		divid = document.getElementById(div);
		if(divid.style.display == \'none\') {
			divid.style.display = \'block\';
			document.getElementById(\'show_arrow\').src = "/app/default/www/images/arrow-up.png";
		} else {
			divid.style.display = \'none\';
			document.getElementById(\'show_arrow\').src = "/app/default/www/images/arrow-down.png";
		}
	}
	
	function selectCustomer(){
	
		doajaxAction("/account/selectSupplier",0,\'selectsupplier\');
		popup("selectsupplier");
		
	}
	
	function getPo(){
		doajaxAction("/account/dispatchPohead/",1,\'pohead\',document.getElementById(\'mainForm\'));
		doajaxAction(\'/account/getCustomerPo/customerId/\'+document.getElementById(\'user[customer]\').value,0,\'podetail\');
		document.getElementById(\'detail\').innerHTML = \'\';
	}
	
	function dispatchWithoutPo(obj){
		
		if(document.getElementById(\'user[customer]\').value > 0) {
	
			if (obj.checked) {
				document.getElementById(\'search[pono]\').value = \'\';
				doajaxAction("/account/dispatchPohead/",1,\'pohead\',document.getElementById(\'mainForm\'));
				doajaxAction("/account/dispatchPodetail/",1,\'detail\',document.getElementById(\'mainForm\'));
			} else {
				document.getElementById(\'detail\').innerHTML = \'\';
			}
		} else {
			if (obj.checked) {
					'; ?>

					<?php if ($this->_tpl_vars['usertype'] == 'Exporter'): ?>
					<?php echo '
					
						alert(\'Select Suppleir First\');
						document.getElementById(\'withoutpo\').checked = false;
					'; ?>

					<?php else: ?>
					<?php echo '
					
					
						var inputsupplier = prompt("Supplier Name", "");
						if(inputsupplier.length > 0) {
							doajaxAction("/account/saveCustomer/newsupplier/"+inputsupplier,0,\'customer\',null);
							
						} else {
							alert("Please type the new supplier");
							document.getElementById(\'withoutpo\').checked = false;
						}
					'; ?>

					<?php endif; ?>
					<?php echo '
					
				
			}
		}
	}
	
	function refreshHTML() {
		doajaxAction("/account/dispatchPohead/",1,\'pohead\',document.getElementById(\'mainForm\'));
		document.getElementById(\'withoutpo\').checked = false;
		document.getElementById(\'detail\').innerHTML = \'\';
	}
'; ?>

</script>